



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class ContactUSDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public ContactUSDB()
        {
        }

        public ContactUSDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<ContactUS> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<ContactUS> lstRet = new List<ContactUS>();

            string strQuery = " select " + strTop  + " * from dbo.[ContactUS]  " ;

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    ContactUS obj = new ContactUS();
 if (dr["ID"] != DBNull.Value)
                    {
                        obj.ID = (System.Int64)dr["ID"];
                    }
                    else
                    {
                        obj.ID = -1;
                    } 
 if (dr["ContactTitleAR"] != DBNull.Value)
                    {
                        obj.ContactTitleAR = (System.String)dr["ContactTitleAR"];
                    }
                    else
                    {
                        obj.ContactTitleAR = "";
                    } 
 if (dr["ContactTitleEN"] != DBNull.Value)
                    {
                        obj.ContactTitleEN = (System.String)dr["ContactTitleEN"];
                    }
                    else
                    {
                        obj.ContactTitleEN = "";
                    } 
 if (dr["Phone1"] != DBNull.Value)
                    {
                        obj.Phone1 = (System.String)dr["Phone1"];
                    }
                    else
                    {
                        obj.Phone1 = "";
                    } 
 if (dr["InnerPhone1"] != DBNull.Value)
                    {
                        obj.InnerPhone1 = (System.String)dr["InnerPhone1"];
                    }
                    else
                    {
                        obj.InnerPhone1 = "";
                    } 
 if (dr["Phone2"] != DBNull.Value)
                    {
                        obj.Phone2 = (System.String)dr["Phone2"];
                    }
                    else
                    {
                        obj.Phone2 = "";
                    } 
 if (dr["InnerPhone2"] != DBNull.Value)
                    {
                        obj.InnerPhone2 = (System.String)dr["InnerPhone2"];
                    }
                    else
                    {
                        obj.InnerPhone2 = "";
                    } 
 if (dr["Mobile1"] != DBNull.Value)
                    {
                        obj.Mobile1 = (System.String)dr["Mobile1"];
                    }
                    else
                    {
                        obj.Mobile1 = "";
                    } 
 if (dr["Mobile2"] != DBNull.Value)
                    {
                        obj.Mobile2 = (System.String)dr["Mobile2"];
                    }
                    else
                    {
                        obj.Mobile2 = "";
                    } 
 if (dr["Email1"] != DBNull.Value)
                    {
                        obj.Email1 = (System.String)dr["Email1"];
                    }
                    else
                    {
                        obj.Email1 = "";
                    } 
 if (dr["Email2"] != DBNull.Value)
                    {
                        obj.Email2 = (System.String)dr["Email2"];
                    }
                    else
                    {
                        obj.Email2 = "";
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<ContactUS> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<ContactUS> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , ContactUS obj)
        {
            
            

                    DbParameter prmContactTitleAR = con.createParameter();
                    prmContactTitleAR.ParameterName = "@ContactTitleAR";
                    prmContactTitleAR.DbType =DbType.String;
                    if (obj.ContactTitleAR == null)
                    {
                        prmContactTitleAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmContactTitleAR.Value = obj.ContactTitleAR;
                    }
                

                    


                    DbParameter prmContactTitleEN = con.createParameter();
                    prmContactTitleEN.ParameterName = "@ContactTitleEN";
                    prmContactTitleEN.DbType =DbType.String;
                    if (obj.ContactTitleEN == null)
                    {
                        prmContactTitleEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmContactTitleEN.Value = obj.ContactTitleEN;
                    }
                

                    


                    DbParameter prmPhone1 = con.createParameter();
                    prmPhone1.ParameterName = "@Phone1";
                    prmPhone1.DbType =DbType.String;
                    if (obj.Phone1 == null)
                    {
                        prmPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone1.Value = obj.Phone1;
                    }
                

                    


                    DbParameter prmInnerPhone1 = con.createParameter();
                    prmInnerPhone1.ParameterName = "@InnerPhone1";
                    prmInnerPhone1.DbType =DbType.String;
                    if (obj.InnerPhone1 == null)
                    {
                        prmInnerPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone1.Value = obj.InnerPhone1;
                    }
                

                    


                    DbParameter prmPhone2 = con.createParameter();
                    prmPhone2.ParameterName = "@Phone2";
                    prmPhone2.DbType =DbType.String;
                    if (obj.Phone2 == null)
                    {
                        prmPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone2.Value = obj.Phone2;
                    }
                

                    


                    DbParameter prmInnerPhone2 = con.createParameter();
                    prmInnerPhone2.ParameterName = "@InnerPhone2";
                    prmInnerPhone2.DbType =DbType.String;
                    if (obj.InnerPhone2 == null)
                    {
                        prmInnerPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone2.Value = obj.InnerPhone2;
                    }
                

                    


                    DbParameter prmMobile1 = con.createParameter();
                    prmMobile1.ParameterName = "@Mobile1";
                    prmMobile1.DbType =DbType.String;
                    if (obj.Mobile1 == null)
                    {
                        prmMobile1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile1.Value = obj.Mobile1;
                    }
                

                    


                    DbParameter prmMobile2 = con.createParameter();
                    prmMobile2.ParameterName = "@Mobile2";
                    prmMobile2.DbType =DbType.String;
                    if (obj.Mobile2 == null)
                    {
                        prmMobile2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile2.Value = obj.Mobile2;
                    }
                

                    


                    DbParameter prmEmail1 = con.createParameter();
                    prmEmail1.ParameterName = "@Email1";
                    prmEmail1.DbType =DbType.String;
                    if (obj.Email1 == null)
                    {
                        prmEmail1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmail1.Value = obj.Email1;
                    }
                

                    


                    DbParameter prmEmail2 = con.createParameter();
                    prmEmail2.ParameterName = "@Email2";
                    prmEmail2.DbType =DbType.String;
                    if (obj.Email2 == null)
                    {
                        prmEmail2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmail2.Value = obj.Email2;
                    }
                

                    


           



            string strQuery = " insert into dbo.[ContactUS] ([ContactTitleAR],[ContactTitleEN],[Phone1],[InnerPhone1],[Phone2],[InnerPhone2],[Mobile1],[Mobile2],[Email1],[Email2]) VALUES (@ContactTitleAR,@ContactTitleEN,@Phone1,@InnerPhone1,@Phone2,@InnerPhone2,@Mobile1,@Mobile2,@Email1,@Email2) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmContactTitleAR,prmContactTitleEN,prmPhone1,prmInnerPhone1,prmPhone2,prmInnerPhone2,prmMobile1,prmMobile2,prmEmail1,prmEmail2);


                    try
                    {
                        obj.ID = System.Int64.Parse(scope.ToString());
                    }
                    catch
                    {
                        obj.ID = -1;
                    }


                    


           

        }



        public void Insert(ContactUS obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, ContactUS obj)
        {
            
            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmContactTitleAR = con.createParameter();
                    prmContactTitleAR.ParameterName = "@ContactTitleAR";
                    prmContactTitleAR.DbType =DbType.String;
                    if (obj.ContactTitleAR == null)
                    {
                        prmContactTitleAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmContactTitleAR.Value = obj.ContactTitleAR;
                    }
                

                    


                    DbParameter prmContactTitleEN = con.createParameter();
                    prmContactTitleEN.ParameterName = "@ContactTitleEN";
                    prmContactTitleEN.DbType =DbType.String;
                    if (obj.ContactTitleEN == null)
                    {
                        prmContactTitleEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmContactTitleEN.Value = obj.ContactTitleEN;
                    }
                

                    


                    DbParameter prmPhone1 = con.createParameter();
                    prmPhone1.ParameterName = "@Phone1";
                    prmPhone1.DbType =DbType.String;
                    if (obj.Phone1 == null)
                    {
                        prmPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone1.Value = obj.Phone1;
                    }
                

                    


                    DbParameter prmInnerPhone1 = con.createParameter();
                    prmInnerPhone1.ParameterName = "@InnerPhone1";
                    prmInnerPhone1.DbType =DbType.String;
                    if (obj.InnerPhone1 == null)
                    {
                        prmInnerPhone1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone1.Value = obj.InnerPhone1;
                    }
                

                    


                    DbParameter prmPhone2 = con.createParameter();
                    prmPhone2.ParameterName = "@Phone2";
                    prmPhone2.DbType =DbType.String;
                    if (obj.Phone2 == null)
                    {
                        prmPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmPhone2.Value = obj.Phone2;
                    }
                

                    


                    DbParameter prmInnerPhone2 = con.createParameter();
                    prmInnerPhone2.ParameterName = "@InnerPhone2";
                    prmInnerPhone2.DbType =DbType.String;
                    if (obj.InnerPhone2 == null)
                    {
                        prmInnerPhone2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmInnerPhone2.Value = obj.InnerPhone2;
                    }
                

                    


                    DbParameter prmMobile1 = con.createParameter();
                    prmMobile1.ParameterName = "@Mobile1";
                    prmMobile1.DbType =DbType.String;
                    if (obj.Mobile1 == null)
                    {
                        prmMobile1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile1.Value = obj.Mobile1;
                    }
                

                    


                    DbParameter prmMobile2 = con.createParameter();
                    prmMobile2.ParameterName = "@Mobile2";
                    prmMobile2.DbType =DbType.String;
                    if (obj.Mobile2 == null)
                    {
                        prmMobile2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmMobile2.Value = obj.Mobile2;
                    }
                

                    


                    DbParameter prmEmail1 = con.createParameter();
                    prmEmail1.ParameterName = "@Email1";
                    prmEmail1.DbType =DbType.String;
                    if (obj.Email1 == null)
                    {
                        prmEmail1.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmail1.Value = obj.Email1;
                    }
                

                    


                    DbParameter prmEmail2 = con.createParameter();
                    prmEmail2.ParameterName = "@Email2";
                    prmEmail2.DbType =DbType.String;
                    if (obj.Email2 == null)
                    {
                        prmEmail2.Value = DBNull.Value;
                    }
                    else
                    {
                        prmEmail2.Value = obj.Email2;
                    }
                

                    


           



            string strQuery = " update dbo.[ContactUS] set [ContactTitleAR]=@ContactTitleAR,[ContactTitleEN]=@ContactTitleEN,[Phone1]=@Phone1,[InnerPhone1]=@InnerPhone1,[Phone2]=@Phone2,[InnerPhone2]=@InnerPhone2,[Mobile1]=@Mobile1,[Mobile2]=@Mobile2,[Email1]=@Email1,[Email2]=@Email2 where  [ID]=@ID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmID,prmContactTitleAR,prmContactTitleEN,prmPhone1,prmInnerPhone1,prmPhone2,prmInnerPhone2,prmMobile1,prmMobile2,prmEmail1,prmEmail2);

            

        }


        public void Update(ContactUS obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, ContactUS obj)
        {

            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[ContactUS]  where  [ID]=@ID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmID );  

             



        }


        public void Delete( ContactUS obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<ContactUS> getContactUSByID(ClassDataHandler con,System.Int64 ID)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType = DbType.Int64;
                        if (ID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmID.Value = ID;
                        }


                        lstRet = Select(con, "" , " where [ID]=@ID ", prmID);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByID(System.Int64 ID)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByID(con, ID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByContactTitleAR(ClassDataHandler con,System.String ContactTitleAR)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmContactTitleAR = con.createParameter();
                        prmContactTitleAR.ParameterName = "@ContactTitleAR";
                        prmContactTitleAR.DbType = DbType.String;
                        if (ContactTitleAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmContactTitleAR.Value = ContactTitleAR;
                        }


                        lstRet = Select(con, "" , " where [ContactTitleAR]=@ContactTitleAR ", prmContactTitleAR);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByContactTitleAR(System.String ContactTitleAR)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByContactTitleAR(con, ContactTitleAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByContactTitleEN(ClassDataHandler con,System.String ContactTitleEN)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmContactTitleEN = con.createParameter();
                        prmContactTitleEN.ParameterName = "@ContactTitleEN";
                        prmContactTitleEN.DbType = DbType.String;
                        if (ContactTitleEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmContactTitleEN.Value = ContactTitleEN;
                        }


                        lstRet = Select(con, "" , " where [ContactTitleEN]=@ContactTitleEN ", prmContactTitleEN);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByContactTitleEN(System.String ContactTitleEN)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByContactTitleEN(con, ContactTitleEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByPhone1(ClassDataHandler con,System.String Phone1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmPhone1 = con.createParameter();
                        prmPhone1.ParameterName = "@Phone1";
                        prmPhone1.DbType = DbType.String;
                        if (Phone1 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPhone1.Value = Phone1;
                        }


                        lstRet = Select(con, "" , " where [Phone1]=@Phone1 ", prmPhone1);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByPhone1(System.String Phone1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByPhone1(con, Phone1);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByInnerPhone1(ClassDataHandler con,System.String InnerPhone1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmInnerPhone1 = con.createParameter();
                        prmInnerPhone1.ParameterName = "@InnerPhone1";
                        prmInnerPhone1.DbType = DbType.String;
                        if (InnerPhone1 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmInnerPhone1.Value = InnerPhone1;
                        }


                        lstRet = Select(con, "" , " where [InnerPhone1]=@InnerPhone1 ", prmInnerPhone1);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByInnerPhone1(System.String InnerPhone1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByInnerPhone1(con, InnerPhone1);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByPhone2(ClassDataHandler con,System.String Phone2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmPhone2 = con.createParameter();
                        prmPhone2.ParameterName = "@Phone2";
                        prmPhone2.DbType = DbType.String;
                        if (Phone2 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmPhone2.Value = Phone2;
                        }


                        lstRet = Select(con, "" , " where [Phone2]=@Phone2 ", prmPhone2);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByPhone2(System.String Phone2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByPhone2(con, Phone2);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByInnerPhone2(ClassDataHandler con,System.String InnerPhone2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmInnerPhone2 = con.createParameter();
                        prmInnerPhone2.ParameterName = "@InnerPhone2";
                        prmInnerPhone2.DbType = DbType.String;
                        if (InnerPhone2 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmInnerPhone2.Value = InnerPhone2;
                        }


                        lstRet = Select(con, "" , " where [InnerPhone2]=@InnerPhone2 ", prmInnerPhone2);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByInnerPhone2(System.String InnerPhone2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByInnerPhone2(con, InnerPhone2);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByMobile1(ClassDataHandler con,System.String Mobile1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmMobile1 = con.createParameter();
                        prmMobile1.ParameterName = "@Mobile1";
                        prmMobile1.DbType = DbType.String;
                        if (Mobile1 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmMobile1.Value = Mobile1;
                        }


                        lstRet = Select(con, "" , " where [Mobile1]=@Mobile1 ", prmMobile1);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByMobile1(System.String Mobile1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByMobile1(con, Mobile1);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByMobile2(ClassDataHandler con,System.String Mobile2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmMobile2 = con.createParameter();
                        prmMobile2.ParameterName = "@Mobile2";
                        prmMobile2.DbType = DbType.String;
                        if (Mobile2 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmMobile2.Value = Mobile2;
                        }


                        lstRet = Select(con, "" , " where [Mobile2]=@Mobile2 ", prmMobile2);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByMobile2(System.String Mobile2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByMobile2(con, Mobile2);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByEmail1(ClassDataHandler con,System.String Email1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmEmail1 = con.createParameter();
                        prmEmail1.ParameterName = "@Email1";
                        prmEmail1.DbType = DbType.String;
                        if (Email1 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmEmail1.Value = Email1;
                        }


                        lstRet = Select(con, "" , " where [Email1]=@Email1 ", prmEmail1);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByEmail1(System.String Email1)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByEmail1(con, Email1);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<ContactUS> getContactUSByEmail2(ClassDataHandler con,System.String Email2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();


                        DbParameter prmEmail2 = con.createParameter();
                        prmEmail2.ParameterName = "@Email2";
                        prmEmail2.DbType = DbType.String;
                        if (Email2 == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmEmail2.Value = Email2;
                        }


                        lstRet = Select(con, "" , " where [Email2]=@Email2 ", prmEmail2);



                        return lstRet;

                    }


                    public List<ContactUS> getContactUSByEmail2(System.String Email2)
                    {
                        List<ContactUS> lstRet = new List<ContactUS>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getContactUSByEmail2(con, Email2);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<ContactUS> Search(ClassDataHandler con, ContactUS obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID AND ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.ContactTitleAR != "")
                    {
                        DbParameter prmContactTitleAR = con.createParameter();
                        prmContactTitleAR.ParameterName = "@ContactTitleAR";
                        prmContactTitleAR.DbType =DbType.String;
                        if (obj.ContactTitleAR == null)
                        {
                            prmContactTitleAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmContactTitleAR.Value = obj.ContactTitleAR;
                        }
                        strWhere += " [ContactTitleAR]=@ContactTitleAR AND ";
                        lstParameters.Add(prmContactTitleAR);
                     }



                    

                    if (obj.ContactTitleEN != "")
                    {
                        DbParameter prmContactTitleEN = con.createParameter();
                        prmContactTitleEN.ParameterName = "@ContactTitleEN";
                        prmContactTitleEN.DbType =DbType.String;
                        if (obj.ContactTitleEN == null)
                        {
                            prmContactTitleEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmContactTitleEN.Value = obj.ContactTitleEN;
                        }
                        strWhere += " [ContactTitleEN]=@ContactTitleEN AND ";
                        lstParameters.Add(prmContactTitleEN);
                     }



                    

                    if (obj.Phone1 != "")
                    {
                        DbParameter prmPhone1 = con.createParameter();
                        prmPhone1.ParameterName = "@Phone1";
                        prmPhone1.DbType =DbType.String;
                        if (obj.Phone1 == null)
                        {
                            prmPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone1.Value = obj.Phone1;
                        }
                        strWhere += " [Phone1]=@Phone1 AND ";
                        lstParameters.Add(prmPhone1);
                     }



                    

                    if (obj.InnerPhone1 != "")
                    {
                        DbParameter prmInnerPhone1 = con.createParameter();
                        prmInnerPhone1.ParameterName = "@InnerPhone1";
                        prmInnerPhone1.DbType =DbType.String;
                        if (obj.InnerPhone1 == null)
                        {
                            prmInnerPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone1.Value = obj.InnerPhone1;
                        }
                        strWhere += " [InnerPhone1]=@InnerPhone1 AND ";
                        lstParameters.Add(prmInnerPhone1);
                     }



                    

                    if (obj.Phone2 != "")
                    {
                        DbParameter prmPhone2 = con.createParameter();
                        prmPhone2.ParameterName = "@Phone2";
                        prmPhone2.DbType =DbType.String;
                        if (obj.Phone2 == null)
                        {
                            prmPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone2.Value = obj.Phone2;
                        }
                        strWhere += " [Phone2]=@Phone2 AND ";
                        lstParameters.Add(prmPhone2);
                     }



                    

                    if (obj.InnerPhone2 != "")
                    {
                        DbParameter prmInnerPhone2 = con.createParameter();
                        prmInnerPhone2.ParameterName = "@InnerPhone2";
                        prmInnerPhone2.DbType =DbType.String;
                        if (obj.InnerPhone2 == null)
                        {
                            prmInnerPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone2.Value = obj.InnerPhone2;
                        }
                        strWhere += " [InnerPhone2]=@InnerPhone2 AND ";
                        lstParameters.Add(prmInnerPhone2);
                     }



                    

                    if (obj.Mobile1 != "")
                    {
                        DbParameter prmMobile1 = con.createParameter();
                        prmMobile1.ParameterName = "@Mobile1";
                        prmMobile1.DbType =DbType.String;
                        if (obj.Mobile1 == null)
                        {
                            prmMobile1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile1.Value = obj.Mobile1;
                        }
                        strWhere += " [Mobile1]=@Mobile1 AND ";
                        lstParameters.Add(prmMobile1);
                     }



                    

                    if (obj.Mobile2 != "")
                    {
                        DbParameter prmMobile2 = con.createParameter();
                        prmMobile2.ParameterName = "@Mobile2";
                        prmMobile2.DbType =DbType.String;
                        if (obj.Mobile2 == null)
                        {
                            prmMobile2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile2.Value = obj.Mobile2;
                        }
                        strWhere += " [Mobile2]=@Mobile2 AND ";
                        lstParameters.Add(prmMobile2);
                     }



                    

                    if (obj.Email1 != "")
                    {
                        DbParameter prmEmail1 = con.createParameter();
                        prmEmail1.ParameterName = "@Email1";
                        prmEmail1.DbType =DbType.String;
                        if (obj.Email1 == null)
                        {
                            prmEmail1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmail1.Value = obj.Email1;
                        }
                        strWhere += " [Email1]=@Email1 AND ";
                        lstParameters.Add(prmEmail1);
                     }



                    

                    if (obj.Email2 != "")
                    {
                        DbParameter prmEmail2 = con.createParameter();
                        prmEmail2.ParameterName = "@Email2";
                        prmEmail2.DbType =DbType.String;
                        if (obj.Email2 == null)
                        {
                            prmEmail2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmail2.Value = obj.Email2;
                        }
                        strWhere += " [Email2]=@Email2 AND ";
                        lstParameters.Add(prmEmail2);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<ContactUS> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<ContactUS> Search(ContactUS obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<ContactUS> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<ContactUS> SearchOrLike(ClassDataHandler con, ContactUS obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID OR ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.ContactTitleAR != "")
                    {
                        DbParameter prmContactTitleAR = con.createParameter();
                        prmContactTitleAR.ParameterName = "@ContactTitleAR";
                        prmContactTitleAR.DbType =DbType.String;
                        if (obj.ContactTitleAR == null)
                        {
                            prmContactTitleAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmContactTitleAR.Value = obj.ContactTitleAR;
                        }
                        strWhere += " [ContactTitleAR] LIKE @ContactTitleAR OR ";
                        lstParameters.Add(prmContactTitleAR);
                     }



                    

                    if (obj.ContactTitleEN != "")
                    {
                        DbParameter prmContactTitleEN = con.createParameter();
                        prmContactTitleEN.ParameterName = "@ContactTitleEN";
                        prmContactTitleEN.DbType =DbType.String;
                        if (obj.ContactTitleEN == null)
                        {
                            prmContactTitleEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmContactTitleEN.Value = obj.ContactTitleEN;
                        }
                        strWhere += " [ContactTitleEN] LIKE @ContactTitleEN OR ";
                        lstParameters.Add(prmContactTitleEN);
                     }



                    

                    if (obj.Phone1 != "")
                    {
                        DbParameter prmPhone1 = con.createParameter();
                        prmPhone1.ParameterName = "@Phone1";
                        prmPhone1.DbType =DbType.String;
                        if (obj.Phone1 == null)
                        {
                            prmPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone1.Value = obj.Phone1;
                        }
                        strWhere += " [Phone1] LIKE @Phone1 OR ";
                        lstParameters.Add(prmPhone1);
                     }



                    

                    if (obj.InnerPhone1 != "")
                    {
                        DbParameter prmInnerPhone1 = con.createParameter();
                        prmInnerPhone1.ParameterName = "@InnerPhone1";
                        prmInnerPhone1.DbType =DbType.String;
                        if (obj.InnerPhone1 == null)
                        {
                            prmInnerPhone1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone1.Value = obj.InnerPhone1;
                        }
                        strWhere += " [InnerPhone1] LIKE @InnerPhone1 OR ";
                        lstParameters.Add(prmInnerPhone1);
                     }



                    

                    if (obj.Phone2 != "")
                    {
                        DbParameter prmPhone2 = con.createParameter();
                        prmPhone2.ParameterName = "@Phone2";
                        prmPhone2.DbType =DbType.String;
                        if (obj.Phone2 == null)
                        {
                            prmPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmPhone2.Value = obj.Phone2;
                        }
                        strWhere += " [Phone2] LIKE @Phone2 OR ";
                        lstParameters.Add(prmPhone2);
                     }



                    

                    if (obj.InnerPhone2 != "")
                    {
                        DbParameter prmInnerPhone2 = con.createParameter();
                        prmInnerPhone2.ParameterName = "@InnerPhone2";
                        prmInnerPhone2.DbType =DbType.String;
                        if (obj.InnerPhone2 == null)
                        {
                            prmInnerPhone2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmInnerPhone2.Value = obj.InnerPhone2;
                        }
                        strWhere += " [InnerPhone2] LIKE @InnerPhone2 OR ";
                        lstParameters.Add(prmInnerPhone2);
                     }



                    

                    if (obj.Mobile1 != "")
                    {
                        DbParameter prmMobile1 = con.createParameter();
                        prmMobile1.ParameterName = "@Mobile1";
                        prmMobile1.DbType =DbType.String;
                        if (obj.Mobile1 == null)
                        {
                            prmMobile1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile1.Value = obj.Mobile1;
                        }
                        strWhere += " [Mobile1] LIKE @Mobile1 OR ";
                        lstParameters.Add(prmMobile1);
                     }



                    

                    if (obj.Mobile2 != "")
                    {
                        DbParameter prmMobile2 = con.createParameter();
                        prmMobile2.ParameterName = "@Mobile2";
                        prmMobile2.DbType =DbType.String;
                        if (obj.Mobile2 == null)
                        {
                            prmMobile2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmMobile2.Value = obj.Mobile2;
                        }
                        strWhere += " [Mobile2] LIKE @Mobile2 OR ";
                        lstParameters.Add(prmMobile2);
                     }



                    

                    if (obj.Email1 != "")
                    {
                        DbParameter prmEmail1 = con.createParameter();
                        prmEmail1.ParameterName = "@Email1";
                        prmEmail1.DbType =DbType.String;
                        if (obj.Email1 == null)
                        {
                            prmEmail1.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmail1.Value = obj.Email1;
                        }
                        strWhere += " [Email1] LIKE @Email1 OR ";
                        lstParameters.Add(prmEmail1);
                     }



                    

                    if (obj.Email2 != "")
                    {
                        DbParameter prmEmail2 = con.createParameter();
                        prmEmail2.ParameterName = "@Email2";
                        prmEmail2.DbType =DbType.String;
                        if (obj.Email2 == null)
                        {
                            prmEmail2.Value = DBNull.Value;
                        }
                        else
                        {
                            prmEmail2.Value = obj.Email2;
                        }
                        strWhere += " [Email2] LIKE @Email2 OR ";
                        lstParameters.Add(prmEmail2);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<ContactUS> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<ContactUS> SearchOrLike(ContactUS obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<ContactUS> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            